﻿using System;
using System.Windows.Forms;
using LDSProject.Controls;

namespace LDSProject.Forms
{
    public partial class PrintForm : Form
    {
        readonly ChartControl _chart;

        public PrintForm(ChartControl chart)
        {
            InitializeComponent();

            _chart = chart;
        }

        private void btnPrintView_Click(object sender, EventArgs e)
        {
            try
            {
                // Set new print document with custom page printing event handler
                //chart.chart1.Printing.PrintDocument = new PrintDocument();
                //chart.chart1.Printing.PrintDocument.PrintPage += new PrintPageEventHandler(pd_PrintPage);

                // Print preview chart
                _chart.chart1.Printing.PrintPreview();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, @"Chart Control for .NET Framework", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                // Set new print document with custom page printing event handler
                //chart.chart1.Printing.PrintDocument = new PrintDocument();
                //chart.chart1.Printing.PrintDocument.PrintPage += new PrintPageEventHandler(pd_PrintPage);

                // Print preview chart
                _chart.chart1.Printing.Print(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, @"Chart Control for .NET Framework", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
    }
}
